package bancosys.tec.persist.entities.domain;

import java.util.Map;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import jmine.tec.persist.annotation.Alias;
import jmine.tec.persist.annotation.Comment;
import jmine.tec.persist.annotation.Comments;
import jmine.tec.persist.annotation.Constraint;
import jmine.tec.persist.annotation.DefaultValue;
import jmine.tec.persist.annotation.Index;

import org.hibernate.annotations.ForeignKey;
import org.hibernate.annotations.MapKey;
import org.hibernate.annotations.Type;

import bancosys.tec.component.Documentation;
import bancosys.tec.persist.authorization.annotation.DisplayName;
import bancosys.tec.persist.base.enumx.JavaEnumMock;
import bancosys.tec.utils.date.Date;

@Entity
@Table(name = "SUB_PAI")
@Comments({ @Comment(table = "SUB_PAI", column = "ID", value = "NENHUM COMENTARIO") })
@Alias("SP")
@Documentation("Comment de sub pai.")
@ForeignKey(name = "FK_P_SP")
public class SubPaiAnotado extends PaiAnotado {

    private Map<Date, PaiAnotado> subColecaoSemCascade;

    private JavaEnumMock subJavaEnumMock;

    private Set<PaiAnotado> outraColecaoColunaImplicita;

    @ManyToMany(fetch = FetchType.LAZY)
    @MapKey(columns = { @Column(name = "DATA", nullable = false) }, type = @Type(type = "bancosys.tec.persist.hibernate.type.DateType"))
    @JoinTable(name = "SUB_PAI_PAI_SEM_CASCADE", inverseJoinColumns = { @JoinColumn(name = "SUB_PAI_INVERSE_JOIN", nullable = false, updatable = false) }, joinColumns = { @JoinColumn(name = "PAI_JOIN", nullable = false, updatable = false) })
    @Comments({ @Comment(table = "SUB_PAI_PAI_SEM_CASCADE", value = "NENHUM COMENTARIO."),
            @Comment(table = "SUB_PAI_PAI_SEM_CASCADE", column = "DATA", value = "NENHUM COMENTARIO."),
            @Comment(table = "SUB_PAI_PAI_SEM_CASCADE", column = "SUB_PAI_INVERSE_JOIN", value = "NENHUM COMENTARIO."),
            @Comment(table = "SUB_PAI_PAI_SEM_CASCADE", column = "PAI_JOIN", value = "NENHUM COMENTARIO.") })
    @ForeignKey(name = "FK_SP_SPPSC", inverseName = "FK_P_SPPSC")
    @DisplayName("Coleção sem cascade do sub-pai")
    @Alias("SPPSC")
    public Map<Date, PaiAnotado> getSubColecaoSemCascade() {
        return this.subColecaoSemCascade;
    }

    public void setSubColecaoSemCascade(Map<Date, PaiAnotado> subColecaoSemCascade) {
        this.subColecaoSemCascade = subColecaoSemCascade;
    }

    /**
     * @return the subJavaEnumMock
     */
    @Column(name = "SUB_JAVA_ENUM", precision = 2)
    @Constraint(suffix = "0")
    @DefaultValue("0")
    @Documentation("Comment de sub java enum.")
    @Index(columns = { "ID", "SUB_JAVA_ENUM" }, suffix = "0")
    public JavaEnumMock getSubJavaEnumMock() {
        return this.subJavaEnumMock;
    }

    /**
     * @param subJavaEnumMock the subJavaEnumMock to set
     */
    public void setSubJavaEnumMock(JavaEnumMock subJavaEnumMock) {
        this.subJavaEnumMock = subJavaEnumMock;
    }

    /**
     * @return the colecaoColunaImplicita
     */
    @OneToMany(mappedBy = "subPaiAnotado")
    public Set<PaiAnotado> getOutraColecaoColunaImplicita() {
        return this.outraColecaoColunaImplicita;
    }

    /**
     * @param colecaoColunaImplicita the colecaoColunaImplicita to set
     */
    public void setOutraColecaoColunaImplicita(Set<PaiAnotado> colecaoColunaImplicita) {
        this.outraColecaoColunaImplicita = colecaoColunaImplicita;
    }
}
